package com.liuning.pagehelperdemo.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liuning.pagehelperdemo.entity.User;
import com.liuning.pagehelperdemo.mapper.UserMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class TestController {

    @Resource
    private UserMapper userMapper;

    @GetMapping("/user")
    public PageInfo<User> queryUser() {
        PageHelper.startPage(1,10);
        List<User> users = userMapper.queryUserList();
        PageInfo<User> userPageInfo = new PageInfo<>(users);
        System.out.println("总数：" + userPageInfo.getTotal());
        System.out.println("每页大小：" + userPageInfo.getPageSize());
        System.out.println(userPageInfo);
        return userPageInfo;
    }
}
